package com.longge;

import java.util.PriorityQueue;

public class MaxKelements {

    public long maxKelements(int[] nums, int k) {

        long sum = 0;
        PriorityQueue<Long> pq = new PriorityQueue<>((a, b) -> (int)(b - a));
        for (long num : nums) {
            pq.offer(num);
        }
        for (int i = 0; i < k; i++) {
            long num = pq.poll();
            sum+=num;
            double ceil = Math.ceil(num / 3.0);
            pq.offer((long)ceil);
        }
        return sum;
    }

    public static void main(String[] args) {
        new MaxKelements().maxKelements(new int[]{1,10,3,3,3},3);
    }
}
